# -*- coding: utf-8 -*-
import re
import scrapy


class RenrenSpider(scrapy.Spider):
    name = 'renren2'
    allowed_domains = ['renren.com']
    # start_urls = ['http://www.renren.com/964657383/profile']
    start_urls = ['http://www.renren.com/SysHome.do']

    def parse(self, response):
        yield scrapy.FormRequest.from_response(
            response,
            formdata={"email":"15638510391","password":"xyb.1206"},
            callback=self.parse_detial
        )

    def parse_detial(self, response):
        #请求cookie
        cookie = response.request.headers.get("Cookie")
        print(cookie)
        print("*"*50)
        #响应cookie
        Set_cookie = response.headers.get("Set-Cookie")
        print(Set_cookie)
        # print(re.findall("谢书悦", response.body.decode()))
        a = response.xpath("//dd/a[@class='hd-name']/@title").extract_first()
        print(a)